import urllib2
from jsonparser import JSONParser
from modeldata import ModelData

URL_ADDRESS = 'http://localhost/dumper-php/dump.php'

#ask for the getSchema web service
error = 0
try:
    f = urllib2.urlopen(URL_ADDRESS  + '?service=listtables&output=json')
    data = f.read()
    print data
    parser = JSONParser()
    parser.parseSchema(data)
except urllib2.HTTPError, e:
    error = 1
    print e
except:
    error = 2
    print 'Unknown error'


#ask for the second service
try:
    print 'a'
    parser.parseData()
except urllib2.HTTPError, e:
    error = 1
    print e
except:
    error = 2
    print 'Unknown error'

if (error == 0):
    print 'database generated successfully'
    